package cn.kgc83.shengyin.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */

public class Page<T> implements Serializable {

    public static final int PAGESIZE=10;
    private long code=0;
    //本页数据

    private List<T> data = new ArrayList<>(0);
    private long pageNo = 1;///
    private long count;//总数
    private long pageTotal;//总页数
    private int pageSize = PAGESIZE;//

    public Page(){

    }
    public Page(List<T> data, long total, int pageSize) {
        this.data = data;
//        this.count = count;
        this.setCount(total);
        this.pageSize = pageSize;
    }
    public Page(List<T> data, long pageNo, long total, int pageSize) {
        this.data = data;
        this.pageNo = pageNo;
//        this.count = count;
        this.pageSize = pageSize;
        this.setCount(total);

    }

    public long getCode() {
        return code;
    }

    public void setCode(long code) {
        this.code = code;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public long getPageNo() {
        return pageNo;
    }

    public void setPageNo(long pageNo) {
        this.pageNo = pageNo;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
        this.pageTotal = this.count / this.pageSize + (this.count % this.pageSize == 0 ? 0 : 1);
    }

    public long getPageTotal() {
        return pageTotal;
    }

    public void setPageTotal(long pageTotal) {
        this.pageTotal = pageTotal;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
